package org.springperu.aop.demo.service.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springperu.aop.demo.dao.AuditDao;
import org.springperu.aop.demo.model.Audit;
import org.springperu.aop.demo.model.Customer;
import org.springperu.aop.demo.service.AuditService;

@Service("auditService")
public class AuditServiceImpl implements AuditService{
	@Autowired
	AuditDao auditDAO;

	public List getAllAudits() {
		return auditDAO.getAllAudits();
	}

	@Override
	public void saveAudit(Object object) {
		//2)Graba en tabla de auditoria
		Audit audit = new Audit();
		audit.setOperation("INSERT");
		audit.setQuery(object.toString());
		audit.setAudit_date(new Date());
		audit.setUser_id(1L);
		auditDAO.saveAudit(audit);		
	}
}
